package notifier

import (
	"errors"
	"go-learn/go_learn/prometheus/web_hook/global"
)

const PROMEHEUS_DINGTALK = "prometheus_dingtalk"

type DingTalkInterface interface {
	SendMarkdownMsg(title, content string, atMobiles []string) error
}

type DingTalk struct {
	Token     string   `json:"token"`
	Secret    string   `json:"secret"`
	AtMobiles []string `json:"AtMobiles"`
}

func NewDingTalk(name string) (*DingTalk, error) {
	switch name {
	case PROMEHEUS_DINGTALK:
		defaultRobot := global.DefaultRobot
		return NewPrometheusDingTalk(defaultRobot.Token, defaultRobot.Secret, defaultRobot.AtMobiles), nil
	default:
		return nil, errors.New("invalid param")
	}
}
